package cn.tedu.zhxy.controller;


import cn.tedu.zhxy.dto.LoginDTO;
import cn.tedu.zhxy.entity.Admin;
import cn.tedu.zhxy.service.AdminService;
import cn.tedu.zhxy.util.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-07-19
 */
@RestController
@RequestMapping("/sms/adminController")
public class AdminController {
    @Autowired
    private AdminService  adminService;

    @PostMapping("saveOrUpdateAdmin")
    public  Result  saveOrUpdateAdmin(@RequestBody Admin  admin){
        adminService.saveOrUpdate(admin);
        return  Result.ok();
    }

    @DeleteMapping("deleteAdmin")
    public  Result  deleteAdmin(@RequestBody List<Integer> ids){
        adminService.removeByIds(ids);
        return  Result.ok();
    }

    @GetMapping("/getAllAdmin/{page}/{limit}")
    public  Result  getAllAdmin(@PathVariable  Long page, @PathVariable  Long limit,String  adminName){
        Page<Admin>   pageParam = new Page<>();
        IPage<Admin> list = adminService.getAllAdmin(pageParam,adminName);
        return   Result.ok(list);
    }




}

